package com.powernode.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.powernode.domain.ProdComm;
import com.powernode.mapper.ProdCommMapper;
import com.powernode.service.ProdCommService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import java.util.Date;

@Service
@Slf4j
public class ProdCommServiceImpl extends ServiceImpl<ProdCommMapper, ProdComm> implements ProdCommService{

    /**
     * 根据id修改商品评论信息
     *
     * @param prodComm
     * @return
     */
    @Override
    public Boolean modifyProdCommById(ProdComm prodComm) {
        // 如果有回复内容,则设置回复时间和回复状态
        if (StringUtils.hasText(prodComm.getReplyContent())){
            prodComm.setReplyTime(new Date());
            prodComm.setReplySts(1);
        }

        return this.updateById(prodComm);
    }
}
